package DP;

/**
 * @Classname JZ10青蛙跳台阶问题
 * @Description TODO
 * @Date 2022/12/21 11:43
 * @Created by xjl
 */
public class JZ10青蛙跳台阶问题 {

    public int numWays(int n) {
        int a = 1, b = 1, sum;
        for(int i = 0; i < n; i++){
            sum = (a + b) % 1000000007;
            a = b;
            b = sum;
        }
        return a;
    }

    public int numWays2(int n) {
        if (n<2){
            return 1;
        }
        int a=1;
        int b=1;
        int c;
        for (int i=1;i<=n;i++){
            c=(a + b) % 1000000007;
            a=b;
            b=c;
        }
        return a;
    }

    public int numWays3(int n) {
        if (n<2){
            return 1;
        }
        int a=0;
        int b=1;
        int c=1;
        for (int i=2;i<=n;i++){
            a=b;
            b=c;
            c=(a + b) % 1000000007;
        }
        return c;
    }
}
